package bb.lanxing.lib.devices.bici.cmd;

import com.umeng.analytics.pro.cc;
import bb.lanxing.lib.devices.bici.BLECommand;
import java.nio.ByteBuffer;
import java.util.Map;

public class TestCMD extends BLECommand {
    public static final byte BIND_RESULT_FAILED = 0;
    public static final byte BIND_RESULT_SUCCESS = 1;
    public static final byte COMMAND_ID = 8;
    public static final byte CONNECT_RESULT_FAILED = 0;
    public static final byte CONNECT_RESULT_SUCCESS = 1;
    public static final byte KEY_BID_BACK = 3;
    public static final byte KEY_FORMAT = 12;
    public static final byte KEY_GPS = 4;
    public static final byte KEY_GSM_GPRS = 6;
    public static final byte KEY_GSM_MSG = 5;
    public static final byte KEY_GYRO = 7;
    public static final byte KEY_GYRO_BACK = 8;
    public static final byte KEY_LIGHT = 10;
    public static final byte KEY_READ_BID = 1;
    public static final byte KEY_SOUND = 9;
    public static final byte KEY_WRITE_BID = 2;
    private int bid;
    private String gprsUrl;
    private byte gps;
    private String gsmPhone;
    private byte sound;

    public String toString() {
        return null;
    }

    public TestCMD() {
        this.commandId = (byte) 8;
    }

    public TestCMD(byte[] bArr) {
        super(bArr);
    }

    @Override
    public void parseBody(byte[] bArr) {
        if (bArr.length < 3) {
            return;
        }
        ByteBuffer wrap = ByteBuffer.wrap(bArr);
        byte b = wrap.get();
        byte[] bArr2 = new byte[(bArr.length - wrap.getShort()) - 3];
        if (b == 1) {
            this.bid = wrap.getInt();
        }
        wrap.get(bArr2);
        parseBody(bArr2);
    }

    @Override
    protected byte[] encodeCMDBody(Map<Byte, Object> map) {
        int i;
        ByteBuffer allocate = ByteBuffer.allocate(500);
        allocate.put((byte) 8);
        allocate.put((byte) 16);//cc.n
        if (map.get((byte) 1) != null) {
            allocate.put((byte) 1);
            allocate.putShort((short) 4);
            allocate.putInt((Integer) map.get((byte) 1));
            i = 9;
        } else {
            i = 2;
        }
        if (map.get((byte) 12) != null) {
            allocate.put((byte) 12);
            allocate.putShort((short) 0);
            i += 3;
        }
        byte[] bArr = new byte[i];
        allocate.flip();
        allocate.get(bArr);
        return bArr;
    }
}
